import { LoginWxMinResult } from "@/apis/login";
import { defineStore } from "pinia";

import { ref, computed } from 'vue'

export const useMemberStore = defineStore('member',()=>{
  // 会员信息
  const profile = ref<LoginWxMinResult>({} as LoginWxMinResult)

  const setProfile = (val:LoginWxMinResult)=>{
    profile.value = val
  }
 const isLogin =  computed(()=> Boolean(profile.value.token))


  return { profile,setProfile,isLogin }
},{
  persist:{
    storage:{
      setItem(key,value){
         uni.setStorageSync(key,value)
      },
      getItem(key){
        return uni.getStorageSync(key)
      }
    }
  }
})